//
//  main.c
//  3
//
//  Created by apple on 2017/1/3.
//  Copyright © 2017年 apple. All rights reserved.
//

#include <stdio.h>
void selectionmax(int a[],int n);

int main(){
    int N,i,m,x,y=0,j,z;
    int a[100];
    scanf("%d",&N);
    for (i=0; i<N; i++) {
        scanf("%d",&m);
        x=m;
        for (; x>0; i++) {
            x=x/10;
            y++;
        }
        for (j=0; i<y; j++) {
            z=m%10;
            a[j]=z;
            m=m/10;
        }
        selectionmax(a, m);
        for (i=0; i<m; i++) {
            printf("%d",a[i]);
            
        }
    
    
    }
    
}
void selectionmax(int a[],int n){
    int i,j,tem;
    int index;
    for (i=0; i<n-1; i++) {
        index=i;
        for (j=i+1; j<n; j++) {
            if (a[j]>a[index]) {
                index=j;
                if (i!=index) {
                    tem=a[i];
                    a[i]=a[index];
                    a[index]=tem;
                }
            }
        }
    }
}